load("@fbcode_macros//build_defs:cpp_binary.bzl", "cpp_binary")
load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library")
load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest")
load("@fbcode_macros//build_defs/lib:re_test_utils.bzl", "re_test_utils")

oncall("fbcode_entropy_wardens_folly")

cpp_unittest(
    name = "ssl_context_manager_test",
    srcs = ["SSLContextManagerTest.cpp"],
    preprocessor_flags = [
        "-DWANGLE_USE_FOLLY_TESTUTIL=1",
    ],
    remote_execution = re_test_utils.remote_execution_linux_default(),
    deps = [
        "//folly/io/async:async_base",
        "//folly/io/async:ssl_context",
        "//folly/io/async/test:test_ssl_server",
        "//folly/portability:gtest",
        "//folly/testing:test_util",
        "//wangle/acceptor:util",
        "//wangle/ssl:server_ssl_context",
        "//wangle/ssl:ssl_cache_options",
        "//wangle/ssl:ssl_context_manager",
        "//wangle/ssl:tls_ticket_key_manager",
    ],
    external_deps = [
        "glog",
    ],
)

cpp_unittest(
    name = "ssl_ticket_key_manager_test",
    srcs = ["TLSTicketKeyManagerTest.cpp"],
    preprocessor_flags = [
        "-DWANGLE_USE_FOLLY_TESTUTIL=1",
    ],
    remote_execution = re_test_utils.remote_execution_linux_default(),
    deps = [
        ":mock_ssl_stats",
        "//folly/io/async:async_base",
        "//folly/io/async:async_ssl_socket",
        "//folly/io/async:ssl_context",
        "//folly/io/async/test:async_ssl_socket_test_lib",
        "//folly/io/async/test:test_ssl_server",
        "//folly/portability:gmock",
        "//folly/portability:gtest",
        "//folly/testing:test_util",
        "//wangle/ssl:ssl_stats",
        "//wangle/ssl:tls_ticket_key_manager",
    ],
)

cpp_unittest(
    name = "ssl_session_cache_manager_test",
    srcs = [
        "SSLSessionCacheManagerTest.cpp",
    ],
    remote_execution = re_test_utils.remote_execution_linux_default(),
    deps = [
        "//folly:random",
        "//folly/portability:gtest",
        "//wangle/ssl:ssl_session_cache_manager",
    ],
    external_deps = [
        "glog",
    ],
)

cpp_binary(
    name = "sslcachetest",
    srcs = ["SSLCacheTest.cpp"],
    deps = [
        "//folly/io/async:async_base",
        "//folly/io/async:async_socket",
        "//folly/io/async:async_ssl_socket",
        "//folly/portability:gflags",
        "//folly/ssl:ssl_session",
    ],
)

cpp_library(
    name = "ticket_util",
    headers = ["TicketUtil.h"],
    exported_deps = [
        "//folly:range",
        "//folly/container:array",
    ],
)

cpp_library(
    name = "mock_ssl_stats",
    headers = ["MockSSLStats.h"],
    exported_deps = [
        "//folly/portability:gmock",
        "//wangle/ssl:ssl_stats",
    ],
)

cpp_unittest(
    name = "tls_cred_processor_test",
    srcs = ["TLSCredProcessorTest.cpp"],
    remote_execution = re_test_utils.remote_execution_linux_default(),
    deps = [
        ":ticket_util",
        "//folly:file",
        "//folly:file_util",
        "//folly:range",
        "//folly/portability:gtest",
        "//folly/portability:stdlib",
        "//folly/synchronization:baton",
        "//wangle/ssl:tls_cred_processor",
    ],
)

cpp_unittest(
    name = "tls_in_memory_ticket_processor_test",
    srcs = ["TLSInMemoryTicketProcessorTest.cpp"],
    deps = [
        "//folly/portability:gtest",
        "//folly/synchronization:baton",
        "//wangle/ssl:tls_in_memory_ticket_processor",
    ],
)
